package net.zjitc.service.Impl;

import net.zjitc.mapper.BoardMapper;
import net.zjitc.mapper.MovieMapper;
import net.zjitc.pojo.Board;
import net.zjitc.pojo.Movie;
import net.zjitc.service.BoardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author admin
 * @Date 2019/6/12 14:04
 */
@Service
@Transactional
public class BoardServiceImpl implements BoardService {
    @Autowired
    BoardMapper boardMapper;
    @Autowired
    MovieMapper movieMapper;

    @Override
    public List<Board> MovieByticket() {
        List<Board> boardList = boardMapper.MovieByticket();
        for (Board b:boardList
             ) {
            Movie movie = movieMapper.findById(b.getMovie_id());
            b.setMovie(movie);
        }
        return boardList;
    }

    @Override
    public List<Board> MovieByWish() {
        List<Board> boardList = boardMapper.MovieByWish();
        for (Board b:boardList
        ) {
            Movie movie = movieMapper.findById(b.getMovie_id());
            b.setMovie(movie);
        }
        return boardList;
    }

    @Override
    public List<Board> MovieByScore() {
        List<Board> boardList = boardMapper.MovieByScore();
        for (Board b:boardList
        ) {
            Movie movie = movieMapper.findById(b.getMovie_id());
            b.setMovie(movie);
        }
        return boardList;
    }
}
